package com.example.skycode7.util;
import java.sql.Connection;
import java.sql.DriverManager;

public class DBConnection {
    private String FileName;
    private int DBType;
    private Connection conn;
    private  String MySQLDriver;
    private String MySQLURL;
    public DBConnection(){
        conn = null;
    }
    public Connection getConn(){
        DBType =1;
        switch (DBType){
            case 1:
                return (getConnToMySQL());
            default: return  null;
        }
    }
    public Connection getConnToMySQL(){
        try{
            //8.0加。cj 小于5.7不加
            MySQLDriver = "com.mysql.cj.jdbc.Deiver";
            MySQLURL =
                    "jdbc:mysql://localhost:3306/sky?user=root&password=123456"+
                            "&Unicode=true&characterEncoding+utf8";
            Class.forName(MySQLDriver).newInstance();
            conn = DriverManager.getConnection(MySQLURL);
        }catch (Exception e){
            e.printStackTrace();
        }
        return conn;
    }

}